<?php
declare(strict_types=1);

namespace Dreamcat\ConfigClient\Api;

use Dreamcat\ConfigClient\Consts\NacosConst;
use Dreamcat\ConfigClient\Factory\NacosServerFactory;
use Dreamcat\ConfigClient\Popo\NacosNotifiParam;
use PHPUnit\Framework\TestCase;

/**
 * 测试nacos接口
 * @author vijay
 */
class NacosServerTest extends TestCase
{
    /**
     * 测试直接获取配置
     * @return void
     */
    public function testGetConfig(): void
    {
        $server = NacosServerFactory::buildServer();
        $result = $server->getConfig("Crm", NacosConst::DEFAULT_GROUP, "dev");
        var_dump($result);
        self::assertEquals(1, 1);
    }

    public function testNotifications(): void
    {
        $server = NacosServerFactory::buildServer();
        $list = [];
        $obj = new NacosNotifiParam();
        $obj->setDataId("Crm")
            ->setGroup(NacosConst::DEFAULT_GROUP)
            ->setNamespaceName("dev")
            ->setReleaseKey("619af250c8d6d4cd6a27dbc8f593a5a3");
        $list[] = $obj;
        $obj = new NacosNotifiParam();
        $obj->setDataId("demo_test")
            ->setGroup("abc")
            ->setNamespaceName("1ff6791f-7f8e-40a9-b741-0c6d5b327934");
        $list[] = $obj;
        $changes = $server->notifications($list);
        var_dump($changes);
        self::assertEquals(1, 1);
    }
}

# end of file
